package com.person.monitor;

import static com.person.monitor.helper.VolumeHelper.COMMAND_ALARM_MAX;
import static com.person.monitor.helper.VolumeHelper.COMMAND_CLOSE_VOLUME;
import static com.person.monitor.helper.VolumeHelper.COMMAND_OPEN_VOLUME;
import static com.person.monitor.helper.VolumeHelper.EXTRA_COMMAND;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.person.monitor.helper.VolumeHelper;

public class VolumeHelperActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        runExtraCommand(getIntent());
    }

    private void runExtraCommand(Intent intent){
        String extraCommand = intent.getStringExtra(EXTRA_COMMAND);
        if(extraCommand != null) {
            execCommand(extraCommand);
            finish();
        }
    }

    private void execCommand(String extraCommand){
        switch (extraCommand) {
            case COMMAND_CLOSE_VOLUME:
                VolumeHelper.getInstance().closeVolume();
                break;
            case COMMAND_OPEN_VOLUME:
                VolumeHelper.getInstance().openVolume();
                break;
            case COMMAND_ALARM_MAX:
                VolumeHelper.getInstance().checkAlarmVolume();
                break;
            default:
                break;
        }
    }
}
